const path = require('path')
const port = 3000 // dev port'
const name = '领导驾驶舱' // page title
function resolve(dir) {
    return path.join(__dirname, dir)
}
//设置url
// let dominUrl = 'http://114.67.250.8';  //测试
let dominUrl = 'http://116.131.8.40:8888';  //正式

//匹配此 {RegExp} 的资源

const CompressionWebpackPlugin = require('compression-webpack-plugin')
const productionGzipExtensions = ['js', 'css']

module.exports = {
    publicPath: './',
    outputDir: 'dist',
    assetsDir: 'static',
    runtimeCompiler: true,
    lintOnSave: false,
    productionSourceMap: false,
    devServer: {
        port: port,
        overlay: {
            warnings: false,
            errors: true
        },
        proxy: {
            //测试 http://114.67.250.8
            //正式 http://116.131.8.40:8888/
            './': {
                //配置代理
                target: dominUrl,
                changeOrigin: true,
            }
        },
    },

    configureWebpack: {
        plugins: [
            new CompressionWebpackPlugin({
                filename: '[path].gz[query]',   // 提示compression-webpack-plugin@3.0.0的话asset改为filename
                algorithm: 'gzip',
                test: new RegExp('\\.(' + productionGzipExtensions.join('|') + ')$'),
                threshold: 10240,
                minRatio: 0.8,
                // deleteOriginalAssets: true, //删除源文件，不建议
            }),
        ]
    },

    // css: {
    //     loaderOptions: {
    //         postcss: {
    //             plugins: [
    //                 require('postcss-pxtorem')({ // 把px单位换算成rem单位
    //                     rootValue: 192, // 换算的基数(设计图750的根字体为32)
    //                     selectorBlackList: ['weui', 'mu'], // 忽略转换正则匹配项
    //                     propList: ['*']
    //                 })
    //             ]
    //         }
    //     }
    // }

}